import {
	baseUrl
} from '@/common/api/config.js'
const upload = (url, formData = {}) => {
	return new Promise((resolve, reject) => {
		let token = uni.getStorageSync('token')
		uni.uploadFile({
			url: baseUrl + '/member/upload/file',
			filePath: url,
			name: 'file',
			formData,
			header: {
				Authorization: token.token ? 'Bearer ' + token.token : ''
			},
			success: (res) => {
				if(res.statusCode === 200){
					let data = res.data;
					resolve(JSON.parse(data))
				}else{
					uni.$u.toast('网络请求异常')
					reject()
				}
			}
		})
	})
}
export default upload